-- card: 11229 from stack: in -- bmap block id: 11379 -- flags: 0000 -- background id: 8327 -- name: AuxWindow ----- HyperTalk script ----- on opencard set the visible of field 1 to false -- background field set the scroll of card field 1 to 0 set the scroll of card field 2 to 0 set the visible of button "close windows" to false end opencard on closecard set the visible of field 1 to true end closecard -- part 5 (field) -- low flags: 01 -- high flags: 2007 -- rect: left=18 top=32 right=290 bottom=384 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 20 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: XCMD Text -- part 6 (button) -- low flags: 00 -- high flags: 8003 -- rect: left=304 top=299 right=321 bottom=425 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show LSC Source ----- HyperTalk script ----- on mouseUp get the visible of card field "source" set the visible of card field "source" to not it if it is false then set the name of me to "Hide LSC Source" else set the name of me to "Show LSC Source" end if end mouseUp -- part 9 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=394 top=38 right=132 bottom=484 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Copy This ----- HyperTalk script ----- on mouseUp global window1,window2 if window1 is empty then put "150,140,250,240" into aRect auxWindow "open","aux 1",aRect put the result into window1 put the rect of button 2 into aRect auxWindow "use",window1,arect if window2 is not empty then set the visible of card button swap to true end if else put "Its window is already up!" end if set the visible of button "close windows" to true end mouseUp -- part 10 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=395 top=141 right=240 bottom=485 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: This Too! ----- HyperTalk script ----- on mouseUp global window2,window1 if window2 is empty then put "300,140,400,240" into aRect auxWindow "open","aux 2",aRect put the result into window2 put the rect of button 3 into aRect auxWindow "use",window2,arect if window1 is not empty then set the visible of card button swap to true end if else put "Its window is already up!" end if set the visible of button "close windows" to true end mouseUp -- part 11 (button) -- low flags: 80 -- high flags: 8003 -- rect: left=59 top=299 right=322 bottom=170 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Close Windows ----- HyperTalk script ----- on mouseUp global window1,window2 if window1 is not empty then AuxWindow "close",window1 put empty into window1 end if if window2 is not empty then AuxWindow "close",window2 put empty into window2 end if set the visible of me to false set the visible of button "swap" to false put empty end mouseUp -- part 12 (button) -- low flags: 80 -- high flags: 8003 -- rect: left=402 top=254 right=275 bottom=478 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Swap ----- HyperTalk script ----- on mouseUp global window1,window2 if window1 is not empty and window2 is not empty then auxwindow "use",window1,the rect of button 3 auxwindow "use",window2,the rect of button 2 set the visible of button "swap" to false else put "You need both windows up to do this." end if end mouseUp -- part 7 (field) -- low flags: 81 -- high flags: 0007 -- rect: left=18 top=31 right=292 bottom=488 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: source -- part contents for card part 5 ----- text ----- AuxWindow Version 1.0d1 Roger Brown AuxWindow is an XCMD that lets you create a new window that is relatively smart in the HyperCard environment. This XCMD does not do anything especially useful, but can serve as a shell for more elaborate operations. As presented here, AuxWindow lets you create any number of auxiliary windows. For each, you specify a name and a frame rectangle. The window created is of type rDocProc with no go-away box. This is important, because a window nees to be disposed using the XCMD "close" operation so that the window pointer is properly purged. An auxiliary window can be dragged around and put in front or behind other windows such as the tools and pattern pallettes, desk accessories, and other auxiliary windows. The card window will always stay behind, of course. HyperCard is very smart about managing windows. An auxiliary window will properly update its contents because they are stored as a WindowPicture. (See the LSC code.) One oddity is that you must click on the title bar to activate one of them. This is HyperCard's doing. The XCMD as presented here allows you to open a window and later close it. The script must maintain the window pointer in a global. For HyperCard versions later than 1.1 this business could be hidden in a global that never appears in a script. With this version, you can also use a window to hold a drawing. The code calls back to HyperCard to copy a area of the card's paint layer and installs the copy in the aux window using the clipboard. (See the LSC code.) To try it, click on the patterns marked "Copy This!" and "This Too!" on the right side of this card. The patterns you click on will appear in auxiliary windows. Then move them around a bit with other windows present to see what happens. Press the "Swap" button to see the pictures interchange. Finally, close the windows with by pressing the "Close" button. Look at the scripts of these buttons to see how to use the XCMD. INVOKING XScrollBox AuxWindow "open",name of window, frame rect of window the result must be held in a global, this is the Window Pointer AuxWindow "use",window pointer global, rectangle to copy AuxWindow "close", window pointer REVISION HISTORY 1.0d1 7/1/88 add name and frame parameters -- part contents for card part 7 ----- text ----- /* AuxWindow1.0d1.c */ /* version 1 add name and location rect in open */ /* floating window for XCMD */ /* © Trustees of Dartmouth College */ /* written in LightSpeed C © Think Technologies, Inc */ /* by Roger Brown 7/1/88 Courseware Development Group */ /* Creates a floating no go-away window with a picture that is cut from a card. syntax is: AuxWindow "open",name,rectangle of window returns window pointer AuxWindow "use",window pointer,rectangle to copy AuxWindow "close",window pointer */ #include "stddata_ctype.c" #include "QuickDraw.h" #include "FontMgr.h" #include "EventMgr.h" #include "WindowMgr.h" #include "MenuMgr.h" #include "MemoryMgr.h" #include "ResourceMgr.h" #include "ToolboxUtil.h" #include "ControlMgr.h" #include "DialogMgr.h" #include "strings.c" #include "ListMgr.h" #include "HyperXCmd.h" #include "XCmdGlue.inc.c" #define FALSE 0 #define TRUE 1 #define HORIZ 1 #define VERT 2 #define VISIBLE 1 #define XCMDSetupA4() asm {move.l a4,-(sp) \ move.l a0,a4} #define XCMDRestoreA4() asm { move.l (sp)+,A4 } /* globals */ XCmdBlockPtr gParamPtr; WindowPtr theWindow; PicHandle itsPic; Str255 theResult; Rect windowRect,grabRect; /* return the max of two ints */ max(a,b) int a,b; { if (a>b) return a; return b; } /* convert a character to upper case */ int toupper(c) char c; { return( (c>='a')&&(c<='z') ? (c-('a'-'A')) : c ); } /* convert a string to upper case */ ucase(s) char *s; { int i,l; l = strlen(s); for (i=0;iparams[1]); strcpy(theNameStr,theName); theRect = *(gParamPtr->params[2]); strcpy(theRectStr,theRect); windowRect.left = GetHCNumberItem(theRectStr,1); windowRect.top = GetHCNumberItem(theRectStr,2); windowRect.right = GetHCNumberItem(theRectStr,3); windowRect.bottom = GetHCNumberItem(theRectStr,4); CreateWindow(theNameStr,&windowRect); NumToString(theWindow,theResult); PtoCstr(theResult); ShowWindow(theWindow); BringToFront(theWindow); } /* use the window to present the copied picture */ UseWindow() { Ptr theWindowPtr; Ptr theRect; Rect badRect; Str255 wPointer; char message[32],theRectStr[32]; GrafPtr gp; theWindowPtr = *(gParamPtr->params[1]); strcpy(wPointer,theWindowPtr); CtoPstr(wPointer); StringToNum(wPointer,&theWindow); theRect = *(gParamPtr->params[2]); strcpy(theRectStr,theRect); grabRect.left = GetHCNumberItem(theRectStr,1); grabRect.top = GetHCNumberItem(theRectStr,2); grabRect.right = GetHCNumberItem(theRectStr,3); grabRect.bottom = GetHCNumberItem(theRectStr,4); itsPic = GetWindowPic(theWindow); if (itsPic != 0L) KillPicture(itsPic); GetMyPicture(); if (GetHandleSize(itsPic) > 0L ) { SetWindowPic(theWindow,itsPic); GetPort(&gp); SetPort(theWindow); SetOrigin(grabRect.left,grabRect.top); SetPort(theWindow); badRect = (*theWindow).portRect; InvalRect(&badRect); SetPort(gp); BringToFront(theWindow); } NumToString(theWindow,theResult); PtoCstr(theResult); } /* close the window */ CloseWindow() { Ptr theWindowPtr; Str255 wPointer; theWindowPtr = *(gParamPtr->params[1]); strcpy(wPointer,theWindowPtr); CtoPstr(wPointer); StringToNum(wPointer,&theWindow); itsPic = GetWindowPic(theWindow); if (itsPic != 0L) KillPicture(itsPic); DisposeWindow(theWindow); strcpy(theResult,"0"); } /* branch on the opcode given in param[0] */ AuxWindow() { Ptr theMessage; char message[32]; theMessage = *(gParamPtr->params[0]); strcpy(message,theMessage); ucase(message); if (strcmp(message,"OPEN")==0) OpenWindow(); else if (strcmp(message,"USE")==0) UseWindow(); else if (strcmp(message,"CLOSE")==0) CloseWindow(); else { /* undefined message */ SysBeep(0); strcpy(theResult,"Undefined message in clue window XCMD"); } } /* XCMD enty point */ pascal void main(paramPtr) XCmdBlockPtr paramPtr; { long len; Handle resultHandle; XCMDSetupA4(); /* do this if you have global variables */ gParamPtr = paramPtr; AuxWindow(); /* run the main event loop */ len = 1+strlen(theResult); resultHandle = NewHandle(len); HLock(resultHandle); BlockMove(theResult,*resultHandle,len); HUnlock(resultHandle); paramPtr->returnValue = resultHandle; XCMDRestoreA4(); /* and this also */ return; }